﻿@using hc.epm.Common
@using hc.Plat.Common.Extend;
@using hc.epm.ViewModel;
@model MonitorView
@{
    ViewBag.Title = "查看安全检查";
    ViewBag.MonitorRectifRecordId = Model.MonitorRectifRecord == null ? 0 : Model.MonitorRectifRecord.Id;
}
@if (Model.Monitor == null)
{
    <div class="contentData">
        <div class="tab">
            该数据已删除或者不存在！
        </div>
    </div>
}
else {
<div class="contentData">
    <form id="mainForm">
        <div class="tab">
            <div class="long-text">
                <label for="PrejectName">&nbsp;项目名称&nbsp;:</label>
                <input type="text" id="ProjectName" name="ProjectName" value="@Model.Monitor.ProjectName" readonly="readonly" disabled />
                <i class="pic iconfont" width="20" height="30" style="cursor:pointer; left:596px;">&#xe76a;</i>
                <input type="hidden" name="ProjectId" id="ProjectId" value="@Model.Monitor.ProjectId" />
                <input type="hidden" name="MonitorId" id="MonitorId" value="@Model.Monitor.Id" />
            </div>
            <div class="short-text">
                <label>&nbsp;检查日期&nbsp;:</label>
                <input type="text" id="MonitorTime" name="MonitorTime" onClick="WdatePicker({ el: 'MonitorTime' })" disabled value="@(Model.Monitor.MonitorTime == null ? "" : Convert.ToDateTime(Model.Monitor.MonitorTime).ToString("yyyy-MM-dd"))">
                <i onClick="WdatePicker({ el: 'MonitorTime' })" class="pic iconfont" width="20" height="30" style="cursor:pointer">&#xe7e2;</i>
            </div>
            <div class="long-text">
                <label for="Title">&nbsp;检查标题&nbsp;:</label>
                <input type="text" id="Title" name="Title" disabled value="@Model.Monitor.Title" />
            </div>
            <div class="long-text MonitorCompanyName">
                <label>&nbsp;检查单位&nbsp;:</label>
                <input type="text" id="MonitorCompanyName" name="MonitorCompanyName" disabled value="@Model.Monitor.MonitorCompanyName">
                <i class="pic iconfont ff" width="20" height="30" style="cursor:pointer; left:596px;">&#xe76a;</i>
                <input type="hidden" name="MonitorCompanyId" id="MonitorCompanyId" value="@Model.Monitor.MonitorCompanyId" />
            </div>
            <div class="long-text MonitorUserName">
                <label>&nbsp;检查人&nbsp;:</label>
                <input type="text" id="MonitorUserName" name="MonitorUserName" value="@Model.Monitor.MonitorUserName" disabled>
                <i class="pic iconfont ff" width="20" height="30" style="cursor:pointer; left:596px;">&#xe76a;</i>
                <input type="hidden" name="MonitorUserId" id="MonitorUserId" value="@Model.Monitor.MonitorUserId" />
            </div>

            <div class="intro">
                <div><label><span class="star"></span>&nbsp;总结&nbsp;:</label></div>
                <div>
                    <textarea class="sub-description" id="Remark" name="Remark" disabled>@Model.Monitor.Remark</textarea>
                </div>
            </div>

            @if (Model.MonitorDetails != null && Model.MonitorDetails.Count() > 0)
            {
                <div class="intro" style="height:100%;">
                    <div><label>&nbsp;问题&nbsp;:</label></div>
                    <table class="datalist" style="width:80%">
                        <thead>
                            <tr>
                                <th width="30%">问题</th>
                                <th width="25%">整改单位</th>
                                <th width="30%">要求完成日期</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var item in Model.MonitorDetails)
                            {
                                <tr>
                                    <td>@item.Name</td>
                                    <td>@item.RectifCompanyName</td>
                                    <td>
                                        @(item.Deadline == null ? "" : Convert.ToDateTime(item.Deadline).ToString("yyyy-MM-dd"))
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
            }

            <div class="upload" style="margin-bottom:0px;">
                <div><label>&nbsp;附件上传&nbsp;:</label></div>
                <div style="width:100%;margin:3px 20px 20px 0px;" id="fileList">
                    <ul class="fileShow"></ul>
                </div>
            </div>
            @if ((int)RectificationState.Rectificationed == Model.Monitor.State && Model.MonitorRectifRecord != null)
            {
                <br /><br />
                <div class="short-text">
                    <label><span class="star"></span>&nbsp;整改完成时间&nbsp;:</label>
                    <input type="text" id="FinishDate" name="FinishDate" disabled value="@(Model.MonitorRectifRecord.FinishDate == null ? "" : Convert.ToDateTime(Model.MonitorRectifRecord.FinishDate).ToString("yyyy-MM-dd"))">
                    <i class="pic iconfont" width="20" height="30" style="cursor:pointer;">&#xe7e2;</i>
                </div>
                <div class="intro">
                    <div><label><span class="star"></span>&nbsp;整改内容&nbsp;:</label></div>
                    <div>
                        <textarea class="sub-description" id="Content" name="Content" disabled>@Model.MonitorRectifRecord.Content</textarea>
                    </div>
                </div>
                <div class="upload" style="margin-bottom:0px;">
                    <div><label>&nbsp;附件上传&nbsp;:</label></div>
                    <div style="width:100%;margin:3px 20px 20px 0px;" id="fileListFile">
                        <ul class="fileShow"></ul>
                    </div>
                </div>
            }
        </div>
    </form>
    <div class="button-group btn-center">
        @if ((int)RectificationState.Rectificationed == Model.Monitor.State && Model.MonitorRectifRecord != null)
        {
            if (ViewBag.IsEqualId)
            {
                <input type="hidden" name="RectifRecordId" id="RectifRecordId" value="@Model.MonitorRectifRecord.Id" />
                <button type="button" class="checkright Rectif" data-module="SecurityCheck" data-right="AuditRectif">确认</button>
                <button type="button" class="checkright Rectif" data-module="SecurityCheck" data-right="RejectRectif">驳回</button>
            }
        }
        <button type="button" class="exchange">沟通</button>
    </div>
</div>
<script>
    //获取附件
    $.post("/Files/GetFileList", { tableName: 'Epm_Monitor', id: '@Model.Monitor.Id' }, function (data) {
        if (data.Flag) {
            if (data.Data.length > 0) {
                data.Data.forEach(function (item, index, arr) {
                    if (item.ImageType == null) {
                        var odiv = '<li id="' + item.GuidId + '">';
                        odiv += '<div class="downloadFile"><img src="' + getFileImg(item.Name) + '" style="width: 20px;height: 20px;cursor: pointer;" class="imgShow"/><a href="javascript:;" target="_blank">' + item.Name + '</a></div>';
                        odiv += '<div>' + item.Size + '</div>';
                        odiv += '<span style="margin-left:20px;">' + item.CreateUserName + '</span>';
                        odiv += '<span style="margin-left:20px;">' + new Date(formatDateByJson(item.CreateTime)).Format("yyyy-MM-dd") + '</span>';
                        odiv += '<input type="hidden" class="hiddenArea" data-group="' + item.Group + '" data-url="' + item.Url + '" data-filename="' + item.Name + '">';
                        odiv += '</li>';
                        $('#fileList .fileShow').append(odiv);
                    }
                })
            }
        } else {
            parent.layer.alert(data.Message, { icon: 2 });
        }
    });
    $.post("/Files/GetFileList", { tableName: 'Epm_MonitorRectifRecord', id: '@ViewBag.MonitorRectifRecordId' }, function (data) {
        if (data.Flag) {
            if (data.Data.length > 0) {
                data.Data.forEach(function (item, index, arr) {
                    if (item.ImageType == null) {
                        var odiv = '<li id="' + item.GuidId + '">';
                        odiv += '<div class="downloadFile"><img src="' + getFileImg(item.Name) + '" style="width: 20px;height: 20px;cursor: pointer;" class="imgShow"/><a href="javascript:;" target="_blank">' + item.Name + '</a></div>';
                        odiv += '<div>' + item.Size + '</div>';
                        odiv += '<span style="margin-left:20px;">' + item.CreateUserName + '</span>';
                        odiv += '<span style="margin-left:20px;">' + new Date(formatDateByJson(item.CreateTime)).Format("yyyy-MM-dd") + '</span>';
                        odiv += '<input type="hidden" class="hiddenArea" data-group="' + item.Group + '" data-url="' + item.Url + '" data-filename="' + item.Name + '">';
                        odiv += '</li>';
                        $('#fileListFile .fileShow').append(odiv);
                    }
                })
            }
        } else {
            parent.layer.alert(data.Message, { icon: 2 });
        }
    });
    //下载附件
    $("body").on("click", ".downloadFile", function () {
        var group = $(this).parent().find(".hiddenArea").data("group");
        var path = $(this).parent().find(".hiddenArea").data("url");
        var fileName = $(this).parent().find(".hiddenArea").data("filename");
        window.location.href = "/Download/DownLoadHB?group=" + group + "&path=" + path + "&fileName=" + fileName;
    });

    layui.use(['layer', 'element'], function () {
        var layer = layui.layer, element = layui.element, $ = layui.jquery;
        //确认整改结果
        $(".Rectif").click(function () {
            var state = $(this).data("right") == "AuditRectif" ? 95 : 99;
            var msg = (state == 95) ? "请输入审核的备注" : "请输入驳回的理由";
            var id = $("#RectifRecordId").val();
            parent.layer.prompt({
                formType: 2,
                title: '请输入驳回理由',
                yes: function (index, layero) {
                    // 获取文本框输入的值
                    var value = layero.find(".layui-layer-input").val();
                    if (value) {
                        $.post("ConfirmRectifyResult", { id: id, state: state, Remark: value }, function (data) {
                            if (data.Flag) {
                                parent.layer.msg("操作成功", { time: 2000, icon: 1 });
                                location.href = "/Monitor/IndexAQ";
                            } else {
                                parent.layer.alert(data.Message, { icon: 2 });
                            }
                        }, "json");
                    } else {
                        parent.layer.alert(msg, { icon: 2 });
                    }
                }
            });
        });
    });
    //沟通
    $('.exchange').on('click', function () {
        var projectId = $("#ProjectId").val();
        window.location.href = "/Question/Add?businType=SecurityCheck&projectId=" + projectId + "&BusinessId=@Model.Monitor.Id";
    });
</script>
}
